- add_page_specific_style 'page_bundles/branches'
- page_title _('Branches')
- add_to_breadcrumbs(_('Repository'), project_tree_path(@project))

-# Possible values for variables passed down from the projects/branches_controller.rb
-#
-#   @mode   - overview|active|stale|all (default:overview)
-#   @sort   - name_asc|updated_asc|updated_desc

.top-area
  = gl_tabs_nav({ class: 'gl-flex-grow-1 gl-border-b-0' }) do
    = gl_tab_link_to s_('Branches|Overview'), project_branches_path(@project), { item_active: @mode == 'overview', title: s_('Branches|Show overview of the branches') }
    = gl_tab_link_to s_('Branches|Active'), project_branches_filtered_path(@project, state: 'active'), { title: s_('Branches|Show active branches') }
    = gl_tab_link_to s_('Branches|Stale'), project_branches_filtered_path(@project, state: 'stale'), { title: s_('Branches|Show stale branches') }
    = gl_tab_link_to s_('Branches|All'), project_branches_filtered_path(@project, state: 'all'), { item_active: %w[overview active stale].exclude?(@mode), title: s_('Branches|Show all branches') }

  .nav-controls
    #js-branches-sort-dropdown{ data: {
        project_branches_filtered_path: project_branches_path(@project, state: 'all'),
        sort_options: branches_sort_options_hash.to_json,
        show_dropdown: @mode == 'overview' ? 'false' : 'true',
        sorted_by: @sort }
    }

    - if can_view_branch_rules?
      = link_button_to project_settings_repository_path(@project, anchor: 'js-branch-rules') do
        = s_('Branches|View branch rules')

    - if can_push_code?
      = link_button_to new_project_branch_path(@project), variant: :confirm do
        = s_('Branches|New branch')
      .js-delete-merged-branches.gl-w-7{ data: {
          default_branch: @project.repository.root_ref,
          form_path: project_merged_branches_path(@project) }
        }

= render_if_exists 'projects/commits/mirror_status'

- if can_view_branch_rules?
  = render 'branch_rules_info'

.js-branch-list{ data: { diverging_counts_endpoint: diverging_commit_counts_namespace_project_branches_path(@project.namespace, @project, format: :json), default_branch: @project.default_branch } }

- if @gitaly_unavailable
  = render 'shared/errors/gitaly_unavailable', reason: s_('Branches|Unable to load branches')

- elsif @mode == 'overview' && (@active_branches.any? || @stale_branches.any?)
  = render "projects/branches/panel", branches: @active_branches, state: 'active', panel_title: s_('Branches|Active branches'), show_more_text: s_('Branches|Show more active branches'), project: @project, overview_max_branches: @overview_max_branches
  = render "projects/branches/panel", branches: @stale_branches, state: 'stale', panel_title: s_('Branches|Stale branches'), show_more_text: s_('Branches|Show more stale branches'), project: @project, overview_max_branches: @overview_max_branches

- elsif @branches.any?
  %ul.content-list.all-branches
    - @branches.each do |branch|
      = render "projects/branches/branch", branch: branch, merged: @merged_branch_names.include?(branch.name), commit_status: @branch_pipeline_statuses[branch.name], show_commit_status: @branch_pipeline_statuses.any?
  - if Feature.enabled?(:branch_list_keyset_pagination, @project)
    = render('kaminari/gitlab/without_count', previous_path: @prev_path, next_path: @next_path)
  - else
    = paginate @branches, theme: 'gitlab'
- else
  .nothing-here-block
    = s_('Branches|No branches to show')

- if can?(current_user, :push_code, @project)
  .js-delete-branch-modal
